public class Synchronized {
    public static void main(String[] args) {
        Object synchronized1 = new Object();
        Object synchronized2 = new Object();
        Thread t1 = new Thread(()-> {
            System.out.println("t1线程加锁synchronized1");
            synchronized (synchronized1) {
                System.out.println("t1线程获取锁synchronized2中");
                synchronized(synchronized2) {
                    System.out.println("获取");
                }
            }
        });
        Thread t2 = new Thread(()-> {
            System.out.println("t2线程加锁synchronized2");
            synchronized (synchronized2) {
                System.out.println("t1线程获取锁synchronized1中");
                synchronized(synchronized1) {
                    System.out.println("获取");
                }
            }
        });
        t1.start();
        t2.start();
    }
}
